package com.lovo.game;


import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * 玩家类
 */
public class Player extends Role {
    @Override
    public void generateNumbers() {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入四位不重复的数字：");
        int [] numbers = this.getNumbers();
        for(int i = 0;i < 4;i++){
            try{
                System.out.println("输入第"+(i+1)+"位数:");
                numbers[i] = sc.nextInt();
                if(numbers[i] < 0 || numbers[i] > 9){
                    System.out.println("请输入0-9的数字");
                    i--;
                    continue;
                }
                for(int j = 0;j < i;j++){
                    if(numbers[i] == numbers[j]){
                        System.out.println("输入重复的数，请重新输入：");
                        i--;
                        break;
                    }
                }
            }catch(InputMismatchException e){
                System.out.println("请输入数字");
                i--;
                sc.next();
            }

        }

    }
}
